import http from '@/plugins/aixos'

export function findProj(id: number) {
  return http.request<ProjModel>({
    url: `/proj/${id}`,
    method: 'GET',
  })
}

export function findAllProj(args: Record<string, any> = {}) {
  const url =
    '/proj?' +
    Object.entries(args)
      .map(([key, value]) => `${key}=${value}`)
      .join('&')
  return http.request<ProjModel[]>({
    url,
    method: 'GET',
    headers: { Authorization: 'Bearer ' + localStorage.getItem('token') },
  })
}

export function addProj(data: ProjModel) {
  return http.request<ProjModel>({
    url: '/proj',
    method: 'POST',
    data,
    headers: { Authorization: 'Bearer ' + localStorage.getItem('token') },
  })
}

export function delProj(id: number) {
  return http.request<ProjModel>({
    url: `/proj/${id}`,
    method: 'DELETE',
    headers: { Authorization: 'Bearer ' + localStorage.getItem('token') },
  })
}
